﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Super.Entities;
using Super.Infrastructure;
using Super.DomainService;
namespace Super.Web.Controllers
{
    public class UserController : Controller
    {
        public ActionResult Login()
        {
            return View();
        }

        public ActionResult Register()
        {
            return View();
        }



        /// <summary>
        /// 用户注册
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult Register(User user)
        {
            using (var adp=new DbContextAdapter())
            {
                var userService = new BaseService<User>(adp);

                user.RegisterIp = Query.IP;
                user.UserGroup_ID = 1;
                user.RegisterTime = DateTime.Now;
                user.LastVisit = DateTime.Now;
                user.LastIp = Query.IP;
                userService.Repository.Insert(user);

                adp.SaveChanges();

                if(adp.ErrorMessage==null)
                {

                }

            }
            return View();
        }

    }
}
